package collections;

import util.Tracer;

public class Stack <T> {
	private Object[] items;
	private int top;
	public Stack(int capacity)
	{
		items = new Object[capacity];
		top = -1;
	}
	
	public boolean isEmpty()
	{
		return top == -1;
	}
	
	public void push(T t)
	{
		items[++ top] = t;
	}
	
	@SuppressWarnings("unchecked")
	public T pop()
	{
		return (T)items[top --];
	}
	
	public static void main(String[] args) {
		Stack<Integer> stack = new Stack<>(10);
		stack.push(1);
		stack.push(2);
		stack.push(3);

		Tracer.trace(stack.pop());
		Tracer.trace(stack.pop());
		Tracer.trace(stack.pop());
	}
}
